<?php
$screen = Blyn::app()->getUIManager()->getCurrentScreen();
$url = $control->getAjaxLinkUrl('AddCompanyContent', NULL, array(
    'cooker' => 'BWCompanyInfo@AddCompanyContent',
    'activityId' => $activityId,
    'eventId'=> $eventId,
    'contentId'=>$contentId,
        ));
$updateId = $control->getAjaxContainerId();
?>

<?php
$form = $this->beginWidget('CActiveForm', array(
    "id" => "addEventForm",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
?>
<link rel="stylesheet" type="text/css"
      href="<?php echo Yii::app()->request->baseUrl; ?>/css/bootstrap-datetimepicker.min.css" />
<script  type="text/javascript"
         src="<?php echo Yii::app()->request->baseUrl; ?>/js/bootstrap-datetimepicker.min.js"/>
<link rel="stylesheet" type="text/css"
      href="<?php echo Yii::app()->request->baseUrl; ?>/css/summernote/summernote.css" />
<script  type="text/javascript"
         src="<?php echo Yii::app()->request->baseUrl; ?>/css/summernote/summernote.min.js"/>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" />
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.min.css" />
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/theme/blackboard.min.css">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/theme/monokai.min.css">
<style>
    .btn-small{
        height: 25px;
        padding-top: 0px;
    }
</style>
<script type="text/javascript">
    $(function() {
        $('#activeTime-timepicker').datetimepicker({
            language: 'pt-BR'
        });
    });
// this script for collecting the form data and pass to the controller action and doing the on success validations
    function send<?php echo $activityId; ?>() {
         $("#summernote").val($(".note-editable").html());
        var formData = new FormData($("#addEventForm")[0]);
        $.ajax({
            url: '<?php echo $url; ?>',
            type: 'POST',
            data: formData,
            //datatype: 'json',
            // async: false,
            beforeSend: function() {
                $("#ajax-loaderdiv").show();
            },
            success: function(html) {
                // on success do some validation or refresh the content div to display the uploaded images 
                jQuery("#<?php echo $updateId; ?>").html(html);
            },
            complete: function() {
                $("#ajax-loaderdiv").hide();
            },
            error: function(data) {
                alert("There may a error on uploading. Try again later");
            },
            cache: false,
            contentType: false,
            processData: false
        });

        return false;
    }
</script>
<legend><h4><?php
        echo $control->getAjaxLink(array('name' => '功能列表', 'id' => 'showEventList'), array(
            'cooker' => 'BAEvent@showEventList'
        ));
        ?>\
        <?php
        echo $control->getAjaxLink(array('name' => '活动列表', 'id' => 'ShowActivityList'), array(
            'cooker' => 'BWCompanyInfo@ShowActivityList',
            'eventId' => $eventId,
        ));
        ?>\ 
        <?php
        echo $control->getAjaxLink(array('name' => '内容列表', 'id' => 'ShowCompanyContent'), array(
            'cooker' => 'BWCompanyInfo@ShowCompanyContent',
            'activityId' => $activityId,
             'eventId'=>$eventId,
        ));
        ?>\ 
          <?php echo '设置内容'; ?>
    </h4></legend>
<div class="tabbable tabs-right" style="margin-top: 15px;"> <!-- Only required for left/right tabs -->
<!--    <ul class="nav nav-tabs" style="margin-bottom: 15px">
        <li class="active"><a href="#tab1" data-toggle="tab"><?php echo '内容信息'; ?></a></li>       
    </ul>-->
    <div class="tab-content">
        <div class="tab-pane active" id="tab1" style="min-height: 370px">                
            <?php
            $control->renderView('content_add_info', array(
                'activityId' => $activityId,
                'form' => $form,
                'model' => $model,
                'contentNameField' => $contentNameField,
                'contentDescriptionField' => $contentDescriptionField,
                'contentAuthorField' => $contentAuthorField,
                'contentTimeField' => $contentTimeField,
                'contentImageField' => $contentImageField,
            ));
            ?>  
        </div>  
    </div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#summernote').summernote({
  toolbar: [
    //[groupname, [button list]]
     
    ['style', ['style','bold', 'italic', 'underline', 'clear']],
    ['font', ['strikethrough']],
    ['fontsize', ['fontsize']],
    ['color', ['color']],
    ['para', ['ul', 'ol', 'paragraph']],
    ['height', ['height']],
    ['Misc',['codeview']],
  ],
  height:100,
  width:674,
  focus: true,
});
});
</script>
<?php
$this->endWidget();
//echo CHtml::endForm();
?>
<button class="btn" onclick="javascript:send<?php echo $activityId; ?>()"><?php echo '保存内容' ?></button>